<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta http-equiv="Cache-Control" content="max-age=180">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no">
<meta http-equiv="x-dns-prefetch-control" content="on">
<title>评论</title>
<link href="css/iconfont.css" rel="stylesheet" type="text/css" />
<link href="css/basestyle.css" rel="stylesheet" type="text/css" />
<link href="css/bootstrap.css" rel="stylesheet" type="text/css" />
<link href="css/star-rating.css" rel="stylesheet" type="text/css" />
<link href="css/common.css" rel="stylesheet" type="text/css" />
<link href="css/style.css" rel="stylesheet" type="text/css" />
<link href="../css/bootstrap.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="../css/toast.css">

<style type="text/css">

.addImg{
border: 1px solid #efefef;
}
.addImg a,.addImg img{
margin:1rem 0 1rem 1rem;
display:inline-block;
width: 8rem;
height: 8rem;
text-align: center;
line-height: 8rem;
border: 1px solid #efefef;
}
.commentHeader{
position: relative; height: 4rem
}
.commentPic{
position: absolute; top: 0;left: 0; padding:0.5rem
}
.commentPic img{
width: 3rem;height: 3rem
}
.commentCon{
margin-left: 5rem;height: 4rem;
}
.commentCon ul
{
	display: inline-block;
	margin-left: 2rem;
}
.commentCon ul li 
{
line-height: 4rem;
	float: left;
	width: 2rem;
	
}
.commentCon span{
	line-height: 4rem;
	display: inline-block;
}
.commentCon .caption{display: none;}
</style>
</head>
<body style="background:#fff">
<div id="loadingToast" style="opacity: 0; display: none;">
        <div class="weui-mask_transparent"></div>
        <div class="weui-toast">
            <i class="weui-loading weui-icon_toast"></i>
        </div>
</div>
<div class="wx-containe">
 
  
</div>
<div class="ft-blank"></div>
<div class="footer-btn" style="height:5.3rem;"><!-- onclick="tjBtn();" -->
	<a href="javascript:;" class="confirm-btn adres" onclick="tjBtn();">提交评论</a>
</div>
<script type="text/javascript" src="js/jquery-1.10.2.js"></script>
<!-- cookie操作js -->
<script type="text/javascript"src="../js/global.js"></script>
<script type="text/javascript" src="../js/common.js"></script>
<script type="text/javascript" src="../js/bootstrap.min.js"></script>
<script type="text/javascript" src="../js/wxLoginInfo.js"></script>
<script type="text/javascript" src="js/star-rating.js"></script>
<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
<script charset="utf-8" src="../js/StringBuilder.js"></script>
<script charset="utf-8" src="../js/templeteHtml.js"></script>
<script type="text/javascript">
  $(".commentTxt .huifu a.hh-btn").click(function(){
	  $(this).next(".huifutxt").show();
	  })
jQuery(document).ready(function () {
		//加载页面信息
		loginInfo(function(userInfo){
			$.get("../xxorder/getProductByOrderSn",{sn:parseURL(window.location.search).sn,memberId:userInfo.id},
					function(res){
					if(res&&res.code==200){
						var datas=res.data;
						for(var i=0;i< datas.length;i++){
							if(datas[i].thumbnail!=""&&datas[i].thumbnail.indexOf(",")>0){
								datas[i].thumbnail=datas[i].thumbnail.split(",")[0];
							}
							$(".wx-containe").append(String.formatmodel(templete.getOrderPingjia(),datas[i]));
						}
						//加载页面信息完毕之心以下操作
						//实例化评价星级选择
					       loadStar_rating();
					}
				},'json');
		});
		//初始微信图片组件模块
       initWxPhoto();
});
  
	function choosePhoto(_this){
		//选择图片
		 wx.chooseImage({
			  count: 6, // 默认9
			    sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图，默认二者都有
			    sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机，默认二者都有
			    success: function (res) {
			        var localIds = res.localIds; // 返回选定照片的本地ID列表，localId可以作为img标签的src属性显示图片
					for(var i in localIds){
						//图片展示
						var imghtml="<img src='"+localIds[i]+"'/>";
						$(_this).before(imghtml);
						//上传该图片
						wx.uploadImage({
				            localId: localIds[i].toString(), // 需要上传的图片的本地ID，由chooseImage接口获得
				            isShowProgressTips: 1, // 默认为1，显示进度提示
				            success: function (res) {
				                var serverId = res.serverId; // 返回图片的服务器端ID
								$(_this).parent().find("input").val($(_this).parent().find("input").val()+","+serverId);
				               // alert($(_this).parent().find("input").val());
				            }
				        });
					}
			    }
			}); 
		   
	}
	    wx.ready(function(){
		   console.log("配置成功！！！！")
		}); 
		wx.error(function(res){ 
		   console.log("配置失败！！！！")
		}); 
	//绑定提交按钮
	function tjBtn(){
		$("#loadingToast").attr("style","opacity: 1; display: block;");
		var arrs=$(".commentBox");
		var jsonArr=[];
		var json={};
		for(var i=0; i<arrs.length;i++){
			json.product=$(arrs[i]).find("input[name=productId]").val();
			json.score=$(arrs[i]).find("input[name=step]").val();
			json.content=$(arrs[i]).find("textarea").val();
			json.imgStrs=$(arrs[i]).find("input[name=imgStr]").val();
			jsonArr.push(json);
		}
		//提交评论
		loginInfo(function(userInfo){
			$.post("../xxreview/subReview",{sn:parseURL(window.location.search).sn,xxReviewsStr:JSON.stringify(jsonArr),memberId:userInfo.id},function(res){
					if(res&&res.code==200){
						//window.location.href="./pingjiaSuccess.html";
						$("#loadingToast").attr("style","opacity: 0; display: none;");
						floatNotify.simple("评价成功!");
						history.back();
					}
			},'json');
		})
	   }
    function initWxPhoto(){
    	//初始化微信图片组件权限信息
        $.ajax({  
            url: "../wxInterface/getSignature",  
            data: {  
                url: window.location.href  
            },  
            type: 'get',  
            dataType: "json",  
            success: function (ret) {  
                if (ret&&ret.code == 200) {
  				   var datas=ret.data;
                    var timestamp = datas.timestamp;  
                    var noncestr = datas.noncestr;  
                    var signature = datas.signature;  
                    //通过config接口注入权限验证配置  
                    wx.config({  
                        debug: false,  
                        appId: datas.appid,  
                        timestamp: timestamp.toString(),  
                        nonceStr: noncestr,   //生成签名的随机串  
                        signature: signature,  //签名  
                        jsApiList: ['chooseImage', 'uploadImage', 'downloadImage']  
                    });   
                } else {  
                    alert(data.error);  
                }  
            }  
        }); 
   }
</script>
</body>
</html>
